﻿using oldislandapi.IService;
using oldislandapi.Models;
using System.Linq.Expressions;

namespace oldislandapi.Service
{
    public class BookService : IBookService
    {
        public async Task<List<Comment>> GetCommentByBookIdAsync(int bookId)
        => await DBContext.DB.Queryable<Comment>().Where(x => x.Book_Id == bookId).ToListAsync();

        public async Task<List<Hot_book>> GetHotBookListAsync()
        => await DBContext.DB.Queryable<Hot_book>().ToListAsync();

        public async Task<Book> GetSingleDataAsync(Expression<Func<Book, bool>> expression)
         => await DBContext.DB.Queryable<Book>().Where(expression).FirstAsync();
    }
}
